<script setup>
import { computed } from 'vue';
const props = defineProps({
  item: {
    type: Object,
  },
});

const getNodeRole = computed(() => {
  // 获取labels所有的key
  const keyList = Object.keys(props.item.metadata.labels)
  if (keyList.length == 0) {
    return "工作节点"
  }
  // node-role.kubernetes.io/control-plane / master /
  if (keyList.includes('node-role.kubernetes.io/control-plane') || keyList.includes('node-role.kubernetes.io/master') || keyList.includes('node-role.kubernetes.io/test')){
    return "控制节点"
  } 
})


</script>


<template>
  <div>
    <el-descriptions size="large" :column="3" border>
      <el-descriptions-item label="主机名">
        <span>{{ props.item.metadata.name }}</span>
      </el-descriptions-item>

      <el-descriptions-item label="IP">
        <span>{{ props.item.status.addresses[0].address }}</span>
      </el-descriptions-item>
      <el-descriptions-item label="角色">
        <el-tag size="large">{{ getNodeRole }}</el-tag>
      </el-descriptions-item>
    </el-descriptions>
  </div>
</template>
